<extend name="Public/base" />
<block name="body">
    <div class="main-title" style="padding-bottom: 10px;">
        <h2>商品列表</h2>
    </div>
    <div class="cf">
        <div class="fl">
            <a class="btn btn-default" href="{:U('add')}">添  加</a> 
        </div>
        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <div class="sleft">
                <form action="{:U('SpProduct/index')}" method='post' id="form-search">
                    <select name="pStatus" class="search-input" >
                        <volist name="pStatuslist" id="vo1">
                            <option value="{$vo1}" <if condition="$vo1 eq $pStatusValue">selected="selected"</if> >  <eq name="vo1" value="1">正常</eq><eq name="vo1" value="0">已下架</eq>   <eq name="vo1" value="-1">全部状态</eq>   </option>
                        </volist>
                    </select>
                    <select name="pid" class="search-input" >
                        <option value='-1'>全部商品分类</option>
                        <volist name="pcategorylist" id="vo">
                            <option value="{$vo.id}" <if condition="$vo.id eq $pCategoryId">selected="selected"</if>    <eq name="vo.type" value="2">style="background-color:#FFCCFF"</eq> <eq name="vo.isDisposal" value="1">style="background-color:#CCFFFF"</eq>><eq name="vo.type" value="2">-----</eq> {$vo.name} <eq name="vo.type" value="2">[进货商品分类]</eq> <eq name="vo.isDisposal" value="1">[处理品]</eq></option>	
                        </volist>
                    </select>
                    <input type="text" name="name" class="search-input" value="{:I('name')}" placeholder="请输入商品名称">
                    <a class="sch-btn" href="javascript:;" id="search" url="{:U('index')}"><i class="btn-search" id="submit"></i></a>

                </form>
            </div>
        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table>
            <thead>
                <tr>
                    <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                    <th>编号</th>
                    <th>属于</th>
                     <th>唯一编码</th>
                    <th>商品名称</th>
                    <th>库存单位规格编码</th>
                    <th>进货价格（元）</th>
                    <th>库存单位规格倍数</th>
                    <th>销售价格（元）</th>
                    <th></th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
            <notempty name="_list">
                <volist name="_list" id="vo">
                    <tr>
                        <td><input class="ids" type="checkbox" name="id[]" value="{$vo.id}" /></td>
                        <td>{$vo.id} </td>
                        <td>{$vo.pCategoryId|get_sp_pcategory_name} </td>
                        <td>{$vo.code}</td>
                        <td>
                             {$vo.name} <eq name="vo.isNeedCupTip" value="1"><i class="fa fa-print" title="会打印杯贴"></eq></i>  
                        </td>
                        <td>{$vo.stockUnitCode}</td>
                        <td><input type="text" value="{$vo.instockPrice}" style="width: 50px;" class="instockPriceinput"/> <a href="#" data-id="{$vo.id}" class="changeinstockpricebtn">保存</a></td>
                        <td>{$vo.stockUnitMultiple}</td>
                        <td><span style="color: red;">{$vo.sellPrice}元</span>/{$vo.unit} </td>
                        <td>
                    
                    </td>
                    <td>{$vo.status_text}</td>
                    <td>
                        <a href="{:U('SpProduct/edit')}&id={$vo['id']}" class="btn btn-primary">编辑</a>
                        <a href="{:U('SpProduct/changeStatus?id='.$vo['id'])}&method=delete" class="confirm ajax-get btn btn-warning">删除</a>

                        <eq name="vo.status" value="1">
                        <a href="{:U('SpProduct/changeStatus?id='.$vo['id'])}&method=forbid" class="confirm ajax-get btn btn-warning ">禁用</a>
                    <else/>
                    <a href="{:U('SpProduct/changeStatus?id='.$vo['id'])}&method=resume" class="confirm ajax-get btn btn-warning">启用</a>
                    </eq> 

                    </td>
                    </tr>
                </volist>
                <else/>
                <td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
            </notempty>
            </tbody>
        </table>
    </div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

    <script type="text/javascript">
        //搜索查询
        $('#submit').click(function () {
            document.getElementById("form-search").submit()
        });
        
        //修改进货价格代码
        $('.changeinstockpricebtn').click(function () {
            var id=$(this).data('id');
            var instockprice = $(this).prev(".instockPriceinput").val();
            $.post("{:U('changeinstockprice')}", {id:id,instockPrice:instockprice}, function (result) {
                alert(result.msg);
            },'json');
        });
        //导航高亮
        highlight_subnav('{:U('SpProduct/index')}');
    </script>
</block>